﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace Web.User.Storage
{
    public partial class StorageReport : System.Web.UI.Page
    {
        public double numTotol = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataBind();
            }
        }
        private void DataBind()
        {

            common.IsLogin();
            string WBID = Session["WB_ID"].ToString();
            //获取存粮信息
            StringBuilder strSql = new StringBuilder();
            strSql.Append("  SELECT B.strName AS VarietyID,C.strName AS TypeID, D.strName AS TimeID,SUM(StorageNumber) AS StorageNumber");
            strSql.Append("  FROM dbo.Dep_StorageInfo A INNER JOIN  dbo.StorageVariety B ON A.VarietyID=B.ID");
            strSql.Append("  INNER JOIN  dbo.StorageType C ON A.TypeID=C.ID");
            strSql.Append("  INNER JOIN dbo.StorageTime D ON A.TimeID=D.ID");
            strSql.Append("  INNER JOIN dbo.Depositor P ON A.AccountNumber=P.AccountNumber");
            strSql.Append("  ");
            strSql.Append("  where 1=1");
            strSql.Append("  and P.WBID=" + WBID);

            if (Qdtstart.Value.Trim() != "")
            {
                strSql.Append("   AND A.StorageDate> '" + Qdtstart.Value.Trim() + "'");
            }
            if (Qdtend.Value.Trim() != "")
            {
                strSql.Append("   AND A.StorageDate < '" + Qdtend.Value.Trim() + "'");
            }

            strSql.Append("   GROUP BY B.strName ,C.strName,D.strName");
            strSql.Append("  ");


            DataTable dt = SQLHelper.ExecuteDataTable(strSql.ToString());
            Repeater1.DataSource = dt;
            Repeater1.DataBind();


            //合计数据


        }



        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {

            DataBind();

        }
    }
}